from flask import Flask,render_template, request
import 关键词提取 as util
import PoemGenerator as generator
import picture as abc
app = Flask(__name__)


@app.route('/')
def index():
   return render_template("Web.html")


@app.route("/get_data", methods=['get','post'])
def get_data():
    # 获取前端的内容
    data = request.values.get("tt")

    result = util.main(data)

    poem = generator.main(result)


    return poem

@app.route("/post_keyword", methods=['get','post'])
def post_keyword():
     data=request.values.get("keyword")
     poem1 = generator.main(data)
     return poem1

@app.route("/test", methods=['get','post'])
def get_picture():
     print("============")
     data = request.files.get("pic")
     f = open("./static/img/"+data.filename, "wb+")
     f.write(data.read())
     keyword1 = abc.main(data.filename)
     poem2 = generator.main(keyword1)
     return poem2



if __name__ == '__main__':
    app.run()
